// 预加载
$(document).ready(function() {
    layui.use(['form','laydate'], function() {
        var form = layui.form
            ,laydate = layui.laydate

        //日期
        // laydate.render({
        //     elem: '#date1',
        //     format: 'yyyyMMdd'
        // });
        laydate.render({
            elem: '#date2',
            format: 'yyyyMMdd'
        });
        form.on('submit(demo1)',function(data){
            $.ajax({
                type: "post",
                url: "/staff/addStaffInfo",
                dataType: "json",
                traditional: true,
                contentType : 'application/json;charset=utf-8',
                data:
                    JSON.stringify({
                        staName: $('#staName').val(),
                        sex: $('#sex').val(),
                        idCard: $('#idCard').val(),
                        phone: $('#phone').val(),
                        email: $('#email').val(),
                        zg001: $('#zg001').val(),
                        remuneration: $('#remuneration').val(),
                        // birthTime: $('#date1').val(),
                        entryTime: $('#date2').val(),
                        zc001: $('#zc001').val(),
                    }),
                success: function(res) {
                    console.log("添加成功");
                    layui.use('layer', function(){
                        var layer = layui.layer;
                        layer.msg('添加成功');
                        $('#staName').val(''),
                        $('#sex').val(''),
                        $('#idCard').val(''),
                        $('#phone').val(''),
                        $('#email').val(''),
                        $('#zg001').val(''),
                        // $('#birthTime').val(''),
                        $('#entryTime').val(''),
                        $('#zc001').val(''),
                        $('#remuneration').val('')
                    })
                }
            })
        })
    })
})